<?php

namespace App\Models;


class Config extends Base
{
    protected $table = 'configs';
    static $key;
    const CACHE_KEY = 'config_key_1';

    public static function getItem($id) {
        if (isset(self::$key))
            return self::$key[$id] ?? '';

        $arr = \Cache::rememberForever(self::CACHE_KEY, function () {
            return Config::all()->pluck('value', 'id');
        });
        self::$key = $arr;
        return $arr[$id] ?? '';

    }

    public static function clearCache() {
        \Cache::forget(self::CACHE_KEY);
    }

}
